<template>
  <div class="qualitySafety_container">
    <div class="left_box">
      <div class="box">
        <h6>国际贸易</h6>
        <div class="top">
          <div class="u2">
            <span :class="isShowA == 0 ? 'one' :'five'"
                  @click="bindClickA(0)">近一年</span>
            <span :class="isShowA == 1 ? 'one' :'five'"
                  @click="bindClickA(1)">近五年</span>
          </div>
        </div>
        <div class="market">
          <div id="three">
            <FoldedColumnMixing :option="optionOne"></FoldedColumnMixing>
          </div>
        </div>
      </div>
      <div class="box">
        <h6>前十大市场</h6>
        <CcTable :headData="headData"
                 :tableData="tableData2"
                 :height="height2"
                 :height1="heig"
                 :height2="height4"
                 v-if="tableData2.length > 0">
        </CcTable>
      </div>
    </div>
    <div class="center_box">
      <div class="statistics">
        <h6>汇总信息</h6>
        <Statistics :option="option"></Statistics>
      </div>
      <div class="buttom">
        <h6>贸易市场</h6>
        <div class="u2">
          <span :class="isShowC == 0 ? 'one' :'five'"
                @click="bindClickC(0)">国内贸易</span>
          <span :class="isShowC == 1 ? 'one' :'five'"
                @click="bindClickC(1)">国际贸易</span>
        </div>
      </div>
      <div class="map">
        <ChainMap v-if="isShowC == 0"></ChainMap>
        <InternationalityMap v-else></InternationalityMap>
      </div>
    </div>

    <div class="right_box">
      <div class="box">
        <h6>国内贸易</h6>
        <div class="top">
          <div class="u2">
            <span :class="isShowB == 0 ? 'one' :'five'"
                  @click="bindClickB(0)">近一年</span>
            <span :class="isShowB == 1 ? 'one' :'five'"
                  @click="bindClickB(1)">近五年</span>
          </div>
        </div>
        <div id="three">
          <FoldedColumnMixing :option="optionTow"></FoldedColumnMixing>
        </div>
      </div>
      <div class="box">
        <h6>前十大市场</h6>
        <CcTable :headData="headData1"
                 :tableData="tableData1"
                 :height="height2"
                 :height1="heig"
                 :height2="height4"
                 v-if="tableData1.length > 0"
                 @trading='handClick'>
        </CcTable>
      </div>
    </div>
  </div>

  <!-- <div class="content">
    <ul class="left">
      <li class="left-one">
        <div class="box">
          <h6>国际贸易</h6>
          <div class="top">
            <div class="u2">
              <span :class="isShowA == 0 ? 'one' :'five'"
                    @click="bindClickA(0)">近一年</span>
              <span :class="isShowA == 1 ? 'one' :'five'"
                    @click="bindClickA(1)">近五年</span>
            </div>
          </div>
          <div>
            <div id="three">
              <FoldedColumnMixing :option="optionOne"></FoldedColumnMixing>
            </div>
          </div>
        </div>
      </li>
      <li class="left-one">
        <div class="box">
          <h6>前十大市场</h6>
        </div>
        <CcTable :headData="headData"
                 :tableData="tableData2"
                 :height="height2"
                 :height1="heig"
                 :height2="height4"
                 v-if="tableData2.length > 0">
        </CcTable>
      </li>
    </ul>
    <div class="center">
      <Statistics :option="option"></Statistics>
      <div class="buttom">
        <h6>贸易市场</h6>
        <div class="u2">
          <span :class="isShowC == 0 ? 'one' :'five'"
                @click="bindClickC(0)">国内贸易</span>
          <span :class="isShowC == 1 ? 'one' :'five'"
                @click="bindClickC(1)">国际贸易</span>
        </div>
      </div>
      <ChainMap v-if="isShowC == 0"></ChainMap>
      <InternationalityMap v-else></InternationalityMap>
    </div>
    <ul class="left">
      <li class="left-one">
        <div class="box">
          <h6>国内贸易</h6>
          <div class="top">
            <div class="u2">
              <span :class="isShowB == 0 ? 'one' :'five'"
                    @click="bindClickB(0)">近一年</span>
              <span :class="isShowB == 1 ? 'one' :'five'"
                    @click="bindClickB(1)">近五年</span>
            </div>
          </div>
          <div id="three">
            <FoldedColumnMixing :option="optionTow"></FoldedColumnMixing>
          </div>
        </div>
      </li>
      <li class="left-one">
        <div class="box">
          <h6>前十大市场</h6>
        </div>
        <CcTable :headData="headData1"
                 :tableData="tableData1"
                 :height="height2"
                 :height1="heig"
                 :height2="height4"
                 v-if="tableData1.length > 0"
                 @trading='handClick'>
        </CcTable>
      </li>
    </ul>
  </div> -->
</template>

<script>
import { httpInternationalTradeChart, httpDomesticTradeChart, httpTradeOverviewChart, httpTopTenMarketChart } from '@/common/api/api'
import FoldedColumnMixing from '../../components/foldedColumnMixing.vue'
import Statistics from '../../components/statistics.vue'
import ChainMap from '../../components/chainMap.vue'
import CcTable from '../../components/cc-table.vue'
import InternationalityMap from '../../components/internationalityMap.vue'

export default {
  components: {
    FoldedColumnMixing,
    Statistics,
    ChainMap,
    CcTable,
    InternationalityMap
  },
  data () {
    return {
      isShowA: 0,
      isShowB: 0,
      isShowC: 0,
      option: [
        { id: 1, dataValue: '158', unit: '万吨', dataName: '国际贸易量', color: 'color:#64B7EC' },
        { id: 2, dataValue: '42', unit: '亿元', dataName: '国际贸易额', color: 'color:#F56E6A' },
        { id: 3, dataValue: '85', unit: '万吨', dataName: '国内贸易量', color: 'color:#F69E0D' },
        { id: 4, dataValue: '32', unit: '亿元', dataName: '国内贸易额', color: 'color:#6EC71E' },
      ],
      optionOne: {
        unitA: '单位：万吨',
        unitB: '单位: 亿元',
        nameA: '贸易量',
        nameB: '贸易额',
        maxA: 10,
        maxB: 10,
        intervalA: 2,
        intervalB: 2,
        colorA: 'rgba(246, 158, 13, 1)',
        colorB: 'rgba(72, 126, 234, 1)',
        brokenLineData: [],
        pieData: [],
        date: []
      },
      optionTow: {
        unitA: '单位：万吨',
        unitB: '单位: 亿元',
        nameA: '贸易量',
        nameB: '贸易额',
        maxA: 100,
        maxB: 10,
        intervalA: 20,
        intervalB: 2,
        colorA: 'rgba(49, 222, 155, 1)',
        colorB: 'rgba(72, 126, 234, 1)',
        brokenLineData: [],
        pieData: [],
        date: []
      },
      headData: ['市场名称', '销售额（亿元)', '销售量（万吨)'],
      height2: { height: '60vh' },
      height4: { height: '86%' },
      heig: { height: '4%' },
      tableData1: [],
      headData1: ['市场名称', '销售额（亿元)', '销售量（万吨)'],
      tableData2: [],
      internationalTradeChart: {}
    }
  },
  methods: {
    bindClickA (e) {
      if (e == 0) {
        this.isShowA = e
        this.optionOne.maxA = 10
        this.optionOne.maxB = 10
        this.optionOne.intervalA = 2
        this.optionOne.intervalB = 2
        this.optionOne.date = this.internationalTradeChart.dateListOneYear
        this.optionOne.brokenLineData = this.internationalTradeChart.tradeVolumeListOneYear
        this.optionOne.pieData = this.internationalTradeChart.tradeAmountListOneYear
      } else {
        this.isShowA = e
        this.optionOne.maxA = 100
        this.optionOne.maxB = 100
        this.optionOne.intervalA = 20
        this.optionOne.intervalB = 20
        this.optionOne.date = this.internationalTradeChart.dateListFiveYear
        this.optionOne.brokenLineData = this.internationalTradeChart.tradeVolumeListFiveYear
        this.optionOne.pieData = this.internationalTradeChart.tradeAmountListFiveYear
      }
    },
    bindClickB (e) {
      if (e == 0) {
        this.isShowB = e
        this.optionTow.maxA = 100
        this.optionTow.maxB = 10
        this.optionTow.intervalA = 20
        this.optionTow.intervalB = 2
        this.optionTow.date = this.domesticTradeChart.dateListOneYear
        this.optionTow.brokenLineData = this.domesticTradeChart.tradeVolumeListOneYear
        this.optionTow.pieData = this.domesticTradeChart.tradeAmountListOneYear
      } else {
        this.isShowB = e
        this.optionTow.maxA = 1000
        this.optionTow.maxB = 100
        this.optionTow.intervalA = 200
        this.optionTow.intervalB = 20
        this.optionTow.date = this.domesticTradeChart.dateListFiveYear
        this.optionTow.brokenLineData = this.domesticTradeChart.tradeVolumeListFiveYear
        this.optionTow.pieData = this.domesticTradeChart.tradeAmountListFiveYear
      }
    },
    bindClickC (e) {
      if (e == 0) {
        this.isShowC = e
      } else {
        this.isShowC = e
      }
    },
    handClick () {
      if (this.isShowB == 0) {
        this.optionTow.brokenLineData = [2, 3, 5, 2, 6, 2, 5, 6, 4, 9, 8, 3]
        this.optionTow.pieData = [2, 6, 6, 8, 3, 6, 3, 7, 2, 7, 8, 6]
      }
    },
    getInternationalTradeChart () {
      httpInternationalTradeChart().then(res => {
        const { internationalTradeChart } = res.data
        this.internationalTradeChart = internationalTradeChart
        this.optionOne.date = internationalTradeChart.dateListOneYear
        this.optionOne.brokenLineData = internationalTradeChart.tradeVolumeListOneYear
        this.optionOne.pieData = internationalTradeChart.tradeAmountListOneYear
      })
    },
    getDomesticTradeChart () {
      httpDomesticTradeChart().then(res => {
        const { domesticTradeChart } = res.data
        this.domesticTradeChart = domesticTradeChart
        this.optionTow.date = domesticTradeChart.dateListOneYear
        this.optionTow.brokenLineData = domesticTradeChart.tradeVolumeListOneYear
        this.optionTow.pieData = domesticTradeChart.tradeAmountListOneYear
      })
    },
    getTradeOverviewChart () {
      httpTradeOverviewChart().then(res => {
        const { tradeOverviewEntityList } = res.data
        for (var i = 0; i < this.option.length; i++) {
          for (var j = 0; j < tradeOverviewEntityList.length; j++) {
            var channe = tradeOverviewEntityList[j];
            channe['color'] = this.option[i]
          }
        }
        this.option = tradeOverviewEntityList
      })
    },
    getTopTenMarketChart () {
      httpTopTenMarketChart(0).then(res => {
        const { topTenMarketChart } = res.data
        this.tableData1 = topTenMarketChart
      })
    },
    getTopTenMarketChartOne () {
      httpTopTenMarketChart(1).then(res => {
        const { topTenMarketChart } = res.data
        this.tableData2 = topTenMarketChart
      })
    }

  },
  created () {
    this.getInternationalTradeChart()
    this.getDomesticTradeChart()
    this.getTradeOverviewChart()
    this.getTopTenMarketChart()
    this.getTopTenMarketChartOne()
  },
  mounted () {

  }
}
</script>

<style  lang="scss"  scoped>
.qualitySafety_container {
  height: 89.26%;
  width: 100%;

  display: flex;
  justify-content: space-between;
  .left_box {
    width: calc(100% - 1.56% - 74%);
    height: 100%;
    .box {
      margin-bottom: 0.125rem;
      background-color: #fff;
      padding-top: 0.25rem;
      h6 {
        border-left: 0.05rem solid #487eea;
        padding-left: 0.15rem;
        margin-left: 0.25rem;
      }
      .top {
        position: relative;
        .u2 {
          position: absolute;
          right: 10%;
          bottom: -46;
          z-index: 9999;
          .one {
            width: 1rem;
            height: 0.325rem;
            background: #487eea;
            font-size: 0.175rem;
            font-family: Source Han Sans CN;
            font-weight: 500;
            color: #ffffff;
            border: 1px solid #e4e4e4;
            text-align: center;
            line-height: 0.325rem;
            border-left-style: none;
            padding: 0.05rem 0.075rem;
          }
          .five {
            width: 1rem;
            height: 0.325rem;
            background: #fff;
            font-size: 0.175rem;
            font-family: Source Han Sans CN;
            font-weight: 500;
            color: #666666;
            border: 1px solid #e4e4e4;
            text-align: center;
            line-height: 0.325rem;
            padding: 0.05rem 0.075rem;
          }
        }
      }
    }
  }
  .center_box {
    width: 50%;
    padding: 0 0.15rem 0.075rem 0.15rem;
    .statistics {
      padding-top: 0.25rem;
      background-color: #fff;
      h6 {
        border-left: 0.05rem solid #487eea;
        font-size: 0.225rem;
        color: #000;
        margin-left: 0.25rem;
        padding-left: 0.1125rem;
      }
    }
    .buttom {
      background-color: #fff;
      padding-top: 0.25rem;
      display: flex;
      justify-content: space-between;
      align-items: center;
      h6 {
        border-left: 0.05rem solid #487eea;
        font-size: 0.225rem;
        color: #000;
        margin-left: 0.25rem;
        padding-left: 0.1125rem;
      }
      .u2 {
        padding-right: 0.625rem;
        .one {
          width: 1rem;
          height: 0.325rem;
          background: #487eea;
          font-size: 0.175rem;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #ffffff;
          border: 1px solid #e4e4e4;
          text-align: center;
          line-height: 0.325rem;
          border-left-style: none;
          padding: 0.05rem 0.075rem;
        }
        .five {
          width: 1rem;
          height: 0.325rem;
          background: #fff;
          font-size: 14px;
          font-family: Source Han Sans CN;
          font-weight: 500;
          color: #666666;
          border: 1px solid #e4e4e4;
          text-align: center;
          line-height: 0.325rem;
          padding: 0.05rem 0.075rem;
        }
      }
    }
    .map {
      background-color: #fff;
    }
  }
  .right_box {
    width: calc(100% - 1.56% - 74%);
    height: 100%;
    .box {
      margin-bottom: 0.125rem;
      background-color: #fff;
      padding-top: 0.25rem;
      h6 {
        border-left: 0.05rem solid #487eea;
        padding-left: 0.15rem;
        margin-left: 0.25rem;
      }
      .top {
        position: relative;
        .u2 {
          position: absolute;
          right: 10%;
          bottom: -46;
          z-index: 9999;
          .one {
            width: 1rem;
            height: 0.325rem;
            background: #487eea;
            font-size: 0.175rem;
            font-family: Source Han Sans CN;
            font-weight: 500;
            color: #ffffff;
            border: 1px solid #e4e4e4;
            text-align: center;
            line-height: 0.325rem;
            border-left-style: none;
            padding: 0.05rem 0.075rem;
          }
          .five {
            width: 1rem;
            height: 0.325rem;
            background: #fff;
            font-size: 0.175rem;
            font-family: Source Han Sans CN;
            font-weight: 500;
            color: #666666;
            border: 1px solid #e4e4e4;
            text-align: center;
            line-height: 0.325rem;
            padding: 0.05rem 0.075rem;
          }
        }
      }
    }
  }
}
/* .content {
  display: flex;
  overflow: hidden;
}
.content .left {
  box-sizing: content-box;
  box-sizing: border-box;
  width: 25%;
}
.left-one {
  height: 4.8125rem;
  background: #ffffff;
  margin-top: 0.125rem;
}
.left-one .box {
  padding-top: 0.25rem;
  margin-left: 0.15rem;
}
.left-one .box h6 {
  border-left: 0.05rem solid #487eea;
  padding-left: 0.15rem;
}
.left-one .box .unit {
  padding-top: 0.375rem;
  display: flex;
  justify-content: space-around;
}
.left-one .box .map {
  display: flex;
  justify-content: space-between;
}
.left-one .box .map #one {
  width: 2.5rem;
  height: 2.5rem;
}
.left-one .box .map #two {
  width: 2.5rem;
  height: 2.5rem;
}
.left-one .box #three {
  height: 4.375rem;
}

.content .center {
  flex: 1;
  background: #ffffff;
  margin: 0.125rem;
}
.content .center .buttom {
  margin-left: 0.15rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.buttom .u2 {
  padding-right: 0.625rem;
}
.buttom .u2 .one {
  width: 1rem;
  height: 0.325rem;
  background: #487eea;
  font-size: 0.175rem;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #ffffff;
  border: 1px solid #e4e4e4;
  dataname-align: center;
  line-height: 0.325rem;
  border-left-style: none;
  padding: 0.05rem 0.075rem;
}
.buttom .u2 .five {
  width: 1rem;
  height: 0.325rem;
  background: #fff;
  font-size: 0.175rem;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #666666;
  border: 1px solid #e4e4e4;
  text-align: center;
  line-height: 0.325rem;
  padding: 0.05rem 0.075rem;
}
.content .center .buttom h6 {
  border-left: 0.05rem solid #487eea;
  padding-left: 0.15rem;
}
.left-one .box .top {
  display: flex;
  justify-content: space-between;
  padding-top: 0.225rem;
  padding-right: 0.25rem;
}
.box .top {
  position: relative;
}
.left-one .box .top .u1 {
  font-size: 0.15rem;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}
.box .top .u2 {
  position: absolute;
  left: 34%;
  bottom: -50;
  z-index: 9999;
}
.box .top .u2 .one {
  width: 1rem;
  height: 0.325rem;
  background: #487eea;
  font-size: 0.175rem;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #ffffff;
  border: 1px solid #e4e4e4;
  text-align: center;
  line-height: 0.325rem;
  border-left-style: none;
  padding: 0.05rem 0.075rem;
}
.box .top .u2 .five {
  width: 1rem;
  height: 0.325rem;
  background: #fff;
  font-size: 0.175rem;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #666666;
  border: 1px solid #e4e4e4;
  text-align: center;
  line-height: 0.325rem;
  padding: 0.05rem 0.075rem;
} */
</style>
